package com.oma.testcase;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Logout{
	
	public void logout(WebDriver driver) throws Exception {
		
		WebElement name = driver.findElement(By.xpath("//span[contains(., 'Username:')]"));
		name.click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		WebElement logout = driver.findElement(By.xpath("//a[@href='logout.html' and contains(., 'Sign out')]"));
		logout.click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		
		
		try{
			driver.findElement(By.xpath("//h2[contains(., 'LOG IN')]"));
			System.out.println("Logout successful!");
		}catch(Exception e){
			System.out.println("Logout failed.");
			
		}
	
    }
}
